﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admincp/Admin.Master" AutoEventWireup="true"
    CodeBehind="Menu.aspx.cs" Inherits="TPCN.Admincp.Menu" %>

<asp:Content ID="head" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="name" ContentPlaceHolderID="nameholder" runat="server">Menu</asp:Content>
<asp:Content ID="content" ContentPlaceHolderID="maincontent" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <asp:Panel ID="ButtonPanel" runat="server" CssClass="right">
        <asp:Button ID="btnInsert" runat="server" Text="Thêm menu" CssClass="button button-green"
            OnClick="btnInsert_Click" />
        <asp:Button ID="btnDelete" runat="server" Text="Xóa" CssClass="button button-green"
            OnClick="btnDelete_Click" OnClientClick="return confirm('Bạn có muốn xóa những menu đã chọn không?');" />
    </asp:Panel>
    <asp:ValidationSummary ID="summary" runat="server" CssClass="message error" />
    <asp:Panel ID="ErrorPanel" CssClass="message error ErrorPanel" runat="server" Visible="false">
        <asp:Literal ID="lblMessage" runat="server" />
    </asp:Panel>
    <hr />
    <asp:Panel ID="GridViewPanel" runat="server">
        <asp:GridView ID="MenuGridView" runat="server" AutoGenerateColumns="False" Width="100%"
            DataKeyNames="MenuID" Height="16px" OnRowCommand="MenuGridView_RowCommand" AllowPaging="True"
            GridLines="None" CssClass="mGrid" AlternatingRowStyle-CssClass="alt" PagerStyle-CssClass="pgr"
            OnPageIndexChanging="DanmucGridView_PageIndexChanging" PageSize="15">
            <AlternatingRowStyle CssClass="alt" />
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkSelect" runat="server" CssClass="chkItem" />
                    </ItemTemplate>
                    <HeaderTemplate>
                        <asp:CheckBox ID="chkSelectAll" runat="server" CssClass="chkHeader" />
                    </HeaderTemplate>
                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                </asp:TemplateField>
                <asp:BoundField DataField="MenuID" ReadOnly="True">
                    <HeaderStyle CssClass="hide" />
                    <ItemStyle CssClass="hide" />
                </asp:BoundField>
                <asp:BoundField DataField="Name" HeaderText="Tên hiển thị" />
                <asp:TemplateField HeaderText="Loại">
                    <ItemTemplate>
                        <asp:Label ID="lblLoai" runat="server" Text='<%# BindType(Eval("Type")) %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Vị trí">
                    <ItemTemplate>
                        <asp:Label ID="lblPosition" runat="server" Text='<%# BindPosition(Eval("Position")) %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:CheckBoxField DataField="Active" HeaderText="Hiển thị" />
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="btn_CMD_Edit" runat="server" CommandArgument='<%# Eval("MenuID") %>'
                            CommandName="cmdEdit">Sửa</asp:LinkButton>
                        <asp:LinkButton ID="btn_CMD_Delete" runat="server" CommandArgument='<%# Eval("MenuID") %>'
                            CommandName="cmdDelete" OnClientClick="return confirm('Bạn có muốn xóa menu này không?');">Xóa</asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <HeaderStyle HorizontalAlign="Left" />
            <PagerSettings FirstPageText="Đầu" LastPageText="Cuối" Mode="NumericFirstLast" NextPageText="Tiếp"
                PreviousPageText="Trước" PageButtonCount="5" />
            <PagerStyle CssClass="pgr" />
        </asp:GridView>
    </asp:Panel>
    <asp:Panel ID="EditFormPanel" runat="server">
        <telerik:RadAjaxLoadingPanel ID="loadingPanel" runat="server" MinDisplayTime="0" />
        <asp:Panel ID="updatePanel" runat="server">
            <script type="text/javascript">
                function onMenucboChange() {
                    var type_1 = document.getElementById("<%= type_1.ClientID %>");
                    var type_2 = document.getElementById("<%= type_2.ClientID %>");
                    var type_3 = document.getElementById("<%= type_3.ClientID %>");
                    var cbo = document.getElementById("<%= cboType.ClientID %>");
                    var label = document.getElementById("<%= lblContent.ClientID %>");
                    switch (cbo.selectedIndex) {
                        case 0:
                            type_1.style.display = 'block';
                            type_2.style.display = 'none';
                            type_3.style.display = 'none';
                            label.innerHTML = 'Danh mục';
                            break;
                        case 1:
                            type_1.style.display = 'none';
                            type_2.style.display = 'block';
                            type_3.style.display = 'none';
                            label.innerHTML = 'Link';
                            break;
                        case 2:
                            type_1.style.display = 'none';
                            type_2.style.display = 'none';
                            type_3.style.display = 'block';
                            label.innerHTML = 'Nội dung';
                            break;
                    }
                }
            </script>
            <table id="editForm">
                <tbody>
                    <tr>
                        <td class="label">
                            Tên hiển thị
                        </td>
                        <td>
                            <asp:TextBox ID="txtName" runat="server" Width="230px"></asp:TextBox>
                        </td>
                        <td class="label">
                            Tiêu đề
                        </td>
                        <td>
                            <asp:TextBox ID="txtTitle" runat="server" Width="230px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">
                            Mô tả tìm kiếm
                        </td>
                        <td>
                            <asp:TextBox ID="txtDescription" runat="server" Width="230px"></asp:TextBox>
                        </td>
                        <td class="label">
                            Từ khóa
                        </td>
                        <td>
                            <asp:TextBox ID="txtKeyword" runat="server" Width="230px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">
                            Thứ tự
                        </td>
                        <td>
                            <asp:TextBox ID="txtThutu" runat="server" Width="230px"></asp:TextBox>
                        </td>
                        <td class="label">
                            Vị trí
                        </td>
                        <td>
                            <asp:DropDownList ID="cboPosition" runat="server" Width="244px" OnSelectedIndexChanged="cboPosition_SelectedIndexChanged"
                                AutoPostBack="true">
                                <asp:ListItem Value="0">----- Chọn vị trí -----</asp:ListItem>
                                <asp:ListItem Value="1">Menu chính (bên trên)</asp:ListItem>
                                <asp:ListItem Value="2">Liên kết dưới trang</asp:ListItem>
                            </asp:DropDownList>
                            <asp:CompareValidator ID="CompareValidator2" runat="server" ControlToValidate="cboPosition"
                                ErrorMessage="CompareValidator" Operator="GreaterThan" ValueToCompare="0">*</asp:CompareValidator>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">
                            Thuộc menu
                        </td>
                        <td>
                            <asp:DropDownList ID="cboParentMenu" runat="server" Width="244px">
                            </asp:DropDownList>
                            <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="cboParentMenu"
                                ErrorMessage="CompareValidator" Operator="NotEqual" ValueToCompare="-1">*</asp:CompareValidator>
                        </td>
                        <td class="label">
                            Mở liên kết
                        </td>
                        <td>
                            <asp:DropDownList ID="cboTarget" runat="server" Width="244px">
                                <asp:ListItem Value="_blank">Trong Tab mới</asp:ListItem>
                                <asp:ListItem Value="_self">Trong cửa sổ hiện tại</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">
                            Loại
                        </td>
                        <td>
                            <asp:DropDownList ID="cboType" runat="server" onchange="onMenucboChange();" Width="244px">
                                <asp:ListItem Value="1">Liên kết đến danh mục</asp:ListItem>
                                <asp:ListItem Value="2">Liên kết đến trang khác trên mạng</asp:ListItem>
                                <asp:ListItem Value="3">Trang nội dung</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td class="label">
                            Hiển thị
                        </td>
                        <td>
                            <asp:CheckBox ID="chkActive" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td class="label">
                            <span id="lblContent" runat="server">Danh mục</span>
                        </td>
                        <td colspan="3">
                            <div id="type_1" style="display: block" runat="server">
                                <asp:DropDownList ID="cboCategory" runat="server" Width="244px">
                                </asp:DropDownList>
                            </div>
                            <div id="type_2" style="display: none" runat="server">
                                <asp:TextBox ID="txtLink" runat="server" Width="230px"></asp:TextBox>
                            </div>
                            <div id="type_3" style="display: block" runat="server">
                                <telerik:RadEditor ID="txtContent" runat="server" Height="300px" Width="591px" EditModes="Design, Html"
                                    NewLineBr="False" NewLineMode="Div" ToolsFile="~/Admincp/toolbar.xml">
                                    <Content />
                                </telerik:RadEditor>
                            </div>
                        </td>
                    </tr>
                </tbody>
            </table>
        </asp:Panel>
    <div style="text-align:center">
        <asp:Button ID="btnSave" runat="server" Text="Cập nhật" CssClass="button button-green groupbutton"
            OnClick="btnSave_Click" />
        <asp:Button ID="btnCancel" runat="server" Text="Hủy bỏ" CssClass="button button-green groupbutton"
            OnClick="btnCancel_Click" CausesValidation="False" />
    </div>
    </asp:Panel>
    <telerik:RadAjaxManager ID="mAjaxManager" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="cboPosition">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="updatePanel" LoadingPanelID="loadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <div class="clear">
    </div>
</asp:Content>
